package com.qf.mappers;

import com.qf.pojo.Scene;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/*
杨威
2022/1/2
16:17
*/
public interface SceneMapper {

    @Insert("INSERT INTO sys_scene (scene_name,create_by,create_time) VALUES( #{sceneName},#{createBy},#{createTime})")
    void addScene(Scene scene);

    @Update("UPDATE sys_scene SET status=1 , create_time =#{date} WHERE scene_id =#{scene_id}")
    void reEnableScene(@Param("scene_id") Long sId,@Param("date") Date date);

    @Select("SELECT * FROM sys_scene WHERE create_by=#{uid} and scene_name= #{sceneName}")
    Scene selectByUserIdAndName(@Param("uid") Long uid,@Param("sceneName") String sceneName);

    @Update("UPDATE sys_scene SET  scene_name =#{sceneName} where scene_id= #{sceneId}")
    int updateScene(Scene scene);


    @Select("SELECT * FROM sys_scene WHERE create_by =#{uid} and status=1")
    List<Scene> selectByUserId(Long uid);

    int deleteScenesByIdsAndUid(@Param("ids") List<Long> ids, @Param("userId") Long userId);
}
